<!DOCTYPE html>
<html> 
<?php echo $this->fetch('head.html'); ?>
<body>
<div class="fullscreen">
  <div class="scroll_content">
    <div class="topfixed">
      <div class="t_left"><a href="/index.php?m=ymdian"><i class="back"></i></a></div>
      <div class="t_main">确认订单</div>
    </div>
    <div class="paddingheight"></div>
    <form method="post" id="order-confirm-form" action="/index.php?m=ymdian_order&a=order">
<input type="hidden" name="back_url" value="<?php echo $this->_var['back_url']; ?>" />
<input type="hidden" name="shopid" value="<?php echo $this->_var['ymdian']['id']; ?>">
        <div class="comblock">
       	<h3>
		收货地址&nbsp; <a  href="/index.php?m=user_address&a=add" class="small right" id="add_address">新增地址</a>     
 		</h3>
 	<div class="skyline"></div>
    <ul class=" data-list "id="address_list">
     
    <?php $_from = $this->_var['address']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('k', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['k'] => $this->_var['c']):
?>
    
    <li class="item"> <input type="radio" class="user_address_id" name="user_address_id" <?php if ($this->_var['k'] == 0): ?> checked<?php endif; ?> value="<?php echo $this->_var['c']['id']; ?>"> 地址：<?php echo $this->_var['dist_list'][$this->_var['c']['province_id']]; ?> <?php echo $this->_var['dist_list'][$this->_var['c']['city_id']]; ?> <?php echo $this->_var['dist_list'][$this->_var['c']['town_id']]; ?> <?php echo $this->_var['c']['address']; ?>  姓名：<?php echo $this->_var['c']['truename']; ?> 手机：<?php echo $this->_var['c']['telephone']; ?>
    </li>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </ul>
    </div>

<ul class="cart_new_list clearfix">
        <li>
            <div class="d_name"><?php echo $this->_var['ymdian']['title']; ?>（夜猫寝长）</div>
            <?php $_from = $this->_var['orderCart']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
            <input type="hidden" name="cart_id[]" value="<?php echo $this->_var['c']['id']; ?>" />
            <div class="list clearfix">
                <div class="cart_pic">
                    <a href=""><img src="<?php echo images_site($this->_var['c']['imgurl']); ?>.100x100.jpg" class="img"></a>
                </div>
                <div class="cart_content">
                    <div class="tit"><?php echo $this->_var['c']['title']; ?></div>
                    <div class="info">
                        <p class="fl">
                            <span class="num">￥<?php echo $this->_var['c']['price']; ?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $this->_var['c']['amount']; ?>件</span>
                        </p>

                        <p class="fr">
                            <b class="red">￥<?php echo $this->_var['c']['price']*$this->_var['c']['amount']?></b>
                        </p>
                    </div>

                </div>
            </div>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
            <div class="cart_total">共<?php echo $this->_var['total_num']; ?>件，
                合计：￥<b class="red"><?php echo $this->_var['total_money']; ?></b></div>
        </li>

    </ul>



<div class="comblock">
	
    <dl class="cart_change_dl special clearfix">
            <dt>选择付款方式：</dt>
             <?php $_from = $this->_var['pay_type_list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('k', 'p');$this->_foreach['paylist'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['paylist']['total'] > 0):
    foreach ($_from AS $this->_var['k'] => $this->_var['p']):
        $this->_foreach['paylist']['iteration']++;
?>
              
           <?php if (($this->_foreach['paylist']['iteration'] <= 1)): ?>
           <input type="hidden" name="pay_type" value="<?php echo $this->_var['k']; ?>" id="paytype">
           <?php endif; ?>
            <dd tid="paytype" <?php if (($this->_foreach['paylist']['iteration'] <= 1)): ?> class="cur"<?php endif; ?>  v="<?php echo $this->_var['k']; ?>">
                <span class="select"></span><?php echo $this->_var['p']; ?>
            </dd>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
            
             

        </dl>
  <div>优惠劵：
    <select id="coupon_id" name="coupon_id">
      <option>暂无优惠券</option>
    </select>
  </div>
  <div class="cart_change_notice">
    <textarea class="area"  name="comment" placeholder="可填写您对口味以及配送时间的要求等"></textarea>
  </div>
</div>



<button  id="order-confirm-submit" type="button" class="cart_change_btn">确认购买</button>
 
</form>
 <script>

$(document).on("click",".cart_change_dl dd",function(e) {
	
	 
		$("#paytype").val($(this).attr("v"));
    $(this).addClass("cur").siblings().removeClass("cur");
});
</script>
<script language="javascript">
$(document).ready(function(){
	$.get("/index.php?m=coupon&a=uselist&money=<?php echo $this->_var['total_money']; ?>&type=ymdian&ajax=1",function(data){
		if(data.error==0){
			var html='<option value="0">请选择</option>';
			for(var i=0;i<data.data.length;i++){
				html=html+'<option value="'+data.data[i].id+'">'+data.data[i].title+'</option>';
			}
			$("#coupon_id").empty().append(html);
		}
	},"json")
	
	$(document).on("click","#order-confirm-submit",function(){
		$.post("/index.php?m=ymdian_order&a=order&ajax=1",$("#order-confirm-form").serialize(),function(data){
			if(data.error==0){
				skyToast('订单提交成功');
				window.location=data.url;
			}else{
				skyToast(data.message)
			}
		},"json");
	});
	 
});
	
</script>
<?php echo $this->fetch('footer.html'); ?> </div>
</body>
</html>